package com.example.webrestfulcrud;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.filter.HiddenHttpMethodFilter;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;
import java.util.Map;

@SpringBootApplication
public class WebRestfulCrudApplication {



	public static void main(String[] args) {
		SpringApplication.run(WebRestfulCrudApplication.class, args);
	}

	/**
	 * 将我的自定义视图解析器添加到ICO容器中
	 * alt+shift+n 再按shift切换搜索 搜索 DispatcherServlet
	 * 并在其中的这个方法 打断点
	 * 	protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception
	 * @return
	 */
	@Bean
	public ViewResolver myViewResolver(){
		return new MyViewResolver();
	}

	private static class MyViewResolver implements ViewResolver{

		@Override
		public View resolveViewName(String viewName, Locale locale) throws Exception {
			return new View() {
				@Override
				public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception {

				}
			};
		}
	}
}
